package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domin.vo.QuestionAdminVO;
import com.tianji.learning.query.QuestionAdminPageQuery;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/questions")
@Api(tags = "互动问答相关接口")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {

    private final IInteractionQuestionService questionService;

    @ApiOperation("管理端分页查询互动接口")
    @GetMapping("page")
    public PageDTO<QuestionAdminVO> queryQuestionPageAdmin(QuestionAdminPageQuery query) {
        return questionService.queryQuestionPageAdmin(query);
    }

    @ApiOperation("管理端隐藏或显示接口")
    @PutMapping("/{id}/hidden/{hidden}")
    public void updateHiddenStatus(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden) {
        questionService.updateHiddenStatus(id, hidden);
    }

    @ApiOperation("管理端问题查看详情接口")
    @GetMapping("/{id}")
    public QuestionAdminVO showDescription(@PathVariable("id") Long id) {
        return questionService.showDescription(id);
    }
}